package my.jbf.ALLINONE.DBtest;
import java.util.List;
//import com.example.domain.Person;
//import com.example.service.DBOperateHelper;
//import com.example.service.PersonService;
import android.test.AndroidTestCase;
import android.util.Log;
public class PersonServiceTest extends AndroidTestCase
{
	public void testCreateDB() throws Exception
	{
		DBOperateHelper dbHelper = new DBOperateHelper(getContext());
		dbHelper.getWritableDatabase();
	}
	public void testSave() throws Exception
	{
		PersonService ps = new PersonService(getContext());
		for (int i=1;i <= 100;i++)
		{
			Person person = new Person();
			person.setName("我是" + i);
			person.setPhone(String.valueOf(Long.parseLong("18888888800") + i));
			ps.save(person);
			Log.i("PersonService", person.toString());
		}
	}
	public void testDelete() throws Exception
	{
		PersonService ps = new PersonService(getContext());
		ps.delete(10);
	}
	public void testUpdate() throws Exception
	{
		PersonService ps = new PersonService(getContext());
		ps.update(new Person(1, "xiaopang", "18887654321", 0));
	}
	public void testFind() throws Exception
	{
		PersonService ps = new PersonService(getContext());
		Person person = ps.find(1);
		Log.i("PersonService", person.toString());
	}
	public void testGetScrollData() throws Exception
	{
		PersonService ps = new PersonService(getContext());
		List<Person> persons = ps.getScrollData(3, 5);
		for (Person person:persons)
		{
			Log.i("PersonService", person.toString());
		}
	}
	public void testGetCount() throws Exception
	{
		PersonService ps = new PersonService(getContext());
		Long count = ps.getCount();
		Log.i("PersonService", count.toString());
	}
	public void testUpdateAmount() throws Exception
	{
		PersonService ps = new PersonService(getContext());
		Person person1 = ps.find(1);
		Person person2 = ps.find(2);
		person1.setAmount(100);
		person2.setAmount(100);
		ps.update(person1);
		ps.update(person2);
	}
	public void testPayment() throws Exception
	{
		PersonService ps = new PersonService(getContext());
		ps.payment();
	}
}
